package com.zhuoyue.system.service.impl;

import com.zhuoyue.common.annotation.DataScope;
import com.zhuoyue.system.domain.po.TblFencingPo;
import com.zhuoyue.system.domain.vo.FencingInfoVo;
import com.zhuoyue.system.mapper.TblFencingMapper;
import com.zhuoyue.system.service.ITblFencingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @Author zhanghui
 * @Date: 2021/07/20/10:59
 * @Description:
 */
@Service
public class TblFencingServiceImpl implements ITblFencingService {
    @Autowired
    TblFencingMapper fencingMapper;

    @Override
    @DataScope(deptAlias = "s_d")
    public List<FencingInfoVo> selectFencingInfoList(TblFencingPo tblFencingPo) {
        List<FencingInfoVo> fencingInfoVos = fencingMapper.selectFencingInfoList(tblFencingPo);
        fencingInfoVos.forEach(item -> {
            if (item.getHomeLocation()!=null){
                String detailAddress = item.getHomeLocation().replace("-", "") + item.getHomeAddress();
                item.setDetailAddress(detailAddress);
            }

            Date latestTime = item.getModifyTime() == null ? item.getCreateTime() : item.getModifyTime();
            item.setLatestTime(latestTime);
        });
        return fencingInfoVos;
    }
}
